﻿// Decompiled with JetBrains decompiler
// Type: System.Web.Razor.Parser.ParserVisitor
// Assembly: System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
// MVID: 682513D6-F37E-48AC-9909-F3EE103CFF14
// Assembly location: D:\Project\Idea\无人机外网\uav\客户端工程\排查工具\bin\Release\System.Web.Razor.dll

using System.Threading;
using System.Web.Razor.Parser.SyntaxTree;

namespace System.Web.Razor.Parser
{
  /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Represents a parser visitor.</summary>
  public abstract class ParserVisitor
  {
    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Gets or sets the cancellation token.</summary>
    /// <returns>The cancellation token.</returns>
    public CancellationToken? CancelToken { get; set; }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Visits the specified block.</summary>
    /// <param name="block">The block to visit.</param>
    public virtual void VisitBlock(System.Web.Razor.Parser.SyntaxTree.Block block)
    {
      this.VisitStartBlock(block);
      foreach (SyntaxTreeNode child in block.Children)
        child.Accept(this);
      this.VisitEndBlock(block);
    }

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Visits the specified block before parsing.</summary>
    /// <param name="block">The block to visit.</param>
    public virtual void VisitStartBlock(System.Web.Razor.Parser.SyntaxTree.Block block) => this.ThrowIfCanceled();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Visits the specified span.</summary>
    /// <param name="span">The span to visit.</param>
    public virtual void VisitSpan(Span span) => this.ThrowIfCanceled();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Visits the specified black after parsing.</summary>
    /// <param name="block">The block to visit.</param>
    public virtual void VisitEndBlock(System.Web.Razor.Parser.SyntaxTree.Block block) => this.ThrowIfCanceled();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Visits the given razor error.</summary>
    /// <param name="err">The error to visit.</param>
    public virtual void VisitError(RazorError err) => this.ThrowIfCanceled();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.Indicates that a visitor method has completed execution.</summary>
    public virtual void OnComplete() => this.ThrowIfCanceled();

    /// <summary>This type/member supports the .NET Framework infrastructure and is not intended to be used directly from your code.</summary>
    public virtual void ThrowIfCanceled()
    {
      if (this.CancelToken.HasValue && this.CancelToken.Value.IsCancellationRequested)
        throw new OperationCanceledException();
    }
  }
}
